package main


import (
	"fmt"
	"gitee.com/zhang_banglong/gorm"
	_"gitee.com/zhang_banglong/gorm/dialects/mysql"
)

var Db *gorm.DB
func main(){
	var err error

	mysql_conn := fmt.Sprintf("%s:%s@(%s:%d)/%s?charset=utf8mb4&parseTime=True&loc=Local", "xjlsoft","xjl383", "192.168.195.135", 3306, "girls")

	//赋值给全局变量 Db 没有 := 就是赋值
	Db, err = gorm.Open("mysql", mysql_conn)
	if err != nil{
		panic(err)
	}
	fmt.Println("初始化数据库成功......")
	Db.LogMode(false)  //是否开启log
	//Db.AutoMigrate( &models.Article{},&models.G_count{}) //自动迁移  跟py一样
}

